﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>ValueEvent</Title>
      <Shortcut>#val2</Shortcut>
      <Description>
      </Description>
      <Author>zeroflag</Author>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>Name</ID>
          <ToolTip>The property's name</ToolTip>
          <Default>Property</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>Documentation</ID>
          <ToolTip>The documentation for this property.</ToolTip>
          <Default>//TODO: Add documentation for $Name$</Default>
          <Function>
          </Function>
        </Literal>
        <Object Editable="true">
          <ID>Type</ID>
          <ToolTip>The parameter's type.</ToolTip>
          <Default>string</Default>
          <Function>
          </Function>
        </Object>
      </Declarations>
      <Code Language="csharp">
	<![CDATA[
private $Type$ _$Name$;

#region $Name$

/// <summary>
/// $Documentation$
/// </summary>
public $Type$ $Name$
{
get { return _$Name$; }
set
{
if (_$Name$ != value)
{
this.On$Name$Changed(_$Name$, _$Name$ = value);
}
}
}

#region $Name$Changed event
public delegate void $Name$ChangedHandler(object sender, $Type$ oldvalue, $Type$ newvalue);

private event $Name$ChangedHandler _$Name$Changed;
/// <summary>
/// Occurs when $Name$ changes.
/// </summary>
public event $Name$ChangedHandler $Name$Changed
{
add { this._$Name$Changed += value; }
remove { this._$Name$Changed-= value; }
}

/// <summary>
/// Raises the $Name$Changed event.
/// </summary>
protected virtual void On$Name$Changed($Type$ oldvalue, $Type$ newvalue)
{
if (oldvalue != null)
this.On$Name$Unregister(oldvalue);
if (newvalue != null)
this.On$Name$Register(newvalue);
	
// if there are event subscribers...
if (this._$Name$Changed != null)
{
// call them...
this._$Name$Changed(this, oldvalue, newvalue);
}
}

protected virtual void On$Name$Unregister($Type$ value)
{
}

protected virtual void On$Name$Register($Type$ value)
{
}

#endregion $Name$Changed event
#endregion $Name$
]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>